package com.qf.rabbitmqspringboot.mq;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageDeliveryMode;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class MyListener {

    @RabbitListener(queues = "boot_queue")
    public void consume(String msg, Channel channel, Message message) throws IOException {
        System.out.println("拿到消息：" + msg);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }

}
